package com.h3c.gm.controller

import com.h3c.gm.common.Response
import io.jsonwebtoken.Jwts
import io.jsonwebtoken.SignatureAlgorithm
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

/**
 * Created by d14287 on 2017/6/27.
 */
@RestController
class AuthController {

    /**
     *  登录接口，冗余
     * @return
     */
    @RequestMapping(value = 'auth/login', method = RequestMethod.GET)
    def login() {
        def response = new Response()
        //默认登录成功
        //    throw new ServletException('Invalid login')
        return response.ofSuccess(Jwts.builder()
                .setSubject('gm')
                .signWith(SignatureAlgorithm.HS512, 'secretkey')
                .compact())
    }

}
